package com.yyjj.zixun.activity;

import android.graphics.Color;
import android.os.Bundle;
import android.widget.TextView;

import com.aries.ui.view.title.TitleBarView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.vise.xsnow.http.ViseHttp;
import com.vise.xsnow.http.callback.ACallback;
import com.vise.xsnow.http.mode.CacheMode;
import com.yyjj.zixun.R;
import com.yyjj.zixun.adapter.ZJDAdapter;
import com.yyjj.zixun.api.Api;
import com.yyjj.zixun.entity.JingXuanDetailsEntity;
import com.yyjj.zixun.entity.NeteaseEntity;
import com.yyjj.zixun.entity.ZJDetailsEntity;
import com.yyjj.zixun.entity.ZJEntity;
import com.zzhoujay.richtext.RichText;

import java.util.ArrayList;

import tech.com.commoncore.app.FastManager;
import tech.com.commoncore.base.BaseRefreshLoadActivity;
import tech.com.commoncore.base.BaseTitleActivity;
import tech.com.commoncore.constant.ApiConstant;
import tech.com.commoncore.entity.BaseTResp;

public class JingXuanDetailsActivity extends BaseRefreshLoadActivity<ZJDetailsEntity> {

    String id = "";
//    TextView title;
//    TextView content;


    @Override
    public void beforeSetContentView() {
        super.beforeSetContentView();
        id = (String) getIntent().getSerializableExtra("url");
    }

    @Override
    public void setTitleBar(TitleBarView titleBar) {
        titleBar.setTitleMainText("专家解惑").setTextColor(Color.WHITE);
    }

    @Override
    public int getContentLayout() {
        return R.layout.zixun_activity_netease;
//        return R.layout.zixun_activity_netease_details;
    }

    @Override
    public void initView(Bundle savedInstanceState) {
//        title = findViewById(R.id.tv_title);
//        content = findViewById(R.id.tv_content);
    }


    @Override
    public BaseQuickAdapter<ZJDetailsEntity, BaseViewHolder> getAdapter() {
        return new ZJDAdapter();
    }

    @Override
    public void loadData(int page) {
        ViseHttp.GET(Api.CHARACTER_VIEW)
                .baseUrl(ApiConstant.BASE_URL)
                .addParam("uid", id)
                .addParam("page", "1")
                .setHttpCache(true)
                .cacheMode(CacheMode.FIRST_REMOTE)
                .request(new ACallback<BaseTResp<ArrayList<ZJDetailsEntity>>>() {
                    @Override
                    public void onSuccess(BaseTResp<ArrayList<ZJDetailsEntity>> data) {
                        if (data.data != null) {
                            FastManager.getInstance().getHttpRequestControl().httpRequestSuccess(getIHttpRequestControl(), data.data, null);
                        } else {
                            FastManager.getInstance().getHttpRequestControl().httpRequestSuccess(getIHttpRequestControl(), null, null);
                        }

                    }

                    @Override
                    public void onFail(int errCode, String errMsg) {
                        FastManager.getInstance().getHttpRequestControl().httpRequestSuccess(getIHttpRequestControl(), null, null);
                    }
                });
    }
}
